<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../../views/include/head.jsp"/>
</head>
<body class="leftnav">
<sf:form modelAttribute="userFilter" name="myform">
<table border=0 height="98%" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr><td height="99%" width="100%" align="center" valign="top"> 		
	<table border=0 height="98%" width="100%" cellpadding="0" cellspacing="0" class="linebox">
		<tr class="blueheader">
			<td height="25" align="left">&nbsp;User</td>
		</tr>
		<tr>
			<td height="100" width="100%" align="center" valign="top">
				<table border=1 width="99%" cellpadding="2" cellspacing="0" class="linedropbox">						
					<tr class="header">
						<td height="25" align="left">&nbsp;Tools</td>
					</tr>
					<tr>
						<td width="100%" align="left" valign="middle">
							<br/>
							<table >
								<tbody>
									<tr>
										<td width="100" align="center" class="tool" onclick="javascript:submitAddForm();">
											<a href="#" style="text-decoration: none;"><img src="ico/add.png" border=0/>
											<br/><br/>
											Add User	
											</a>	
										</td>
										<td width="100" align="center" class="tool" onclick="javascript:submitDeleteForm();">
											<a href="#" style="text-decoration: none;"><img src="ico/delete.png" border=0/>
											<br/><br/>
											Delete User
											</a>	
										</td>
										<td width="100" align="center" class="tool" onclick="javascript:submitEditForm();">
											<a href="#" style="text-decoration: none;"><img src="ico/edit.png" border=0/>
											<br/><br/>
											Edit User
											</a>	
										</td>
									</tr>
								</tbody>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>	
		<tr>
			<td width="100%" align="left" valign="top">
				<br/>
				<table border=1 width="99%" cellpadding="2" cellspacing="0" class="linedropbox" align="center" valign="top">
				<tbody>
					<tr class="header">
						<td height="25" align="left">&nbsp;User Management</td>
					</tr>
					<tr>
						<td width="100%" align="left" valign="top">
							<table width="98%"><tbody>
								<tr>
									<td height="25" width="100%" align="left" valign="middle">
										<table border=0> 
										<tbody>
											<tr>
												<td>Username : </td>
												<td><sf:input path="username"/>
												</td>
												<td>&nbsp;Email : </td>
												<td><sf:input path="email"/>
												<td>
													<%--
													<a href="javascript:submitForm();"><img src="ico/search.png" /></a>
													&nbsp;&nbsp;&nbsp;<a href="javascript:submitResetForm();"><img src="ico/clear.png" style="cursor:pointer"/></a>
													 --%>
													<input type="submit" name="_eventId_search" value="Search" class="button blue small"/>
													<input type="submit" name="_eventId_reset" value="Reset" class="button blue small"/>
													<div style="display: none;">
													<input type="submit" name="_eventId_add" value="Add"/>
													<input type="submit" name="_eventId_edit" value="Edit"/>
													<input type="submit" name="_eventId_delete" value="Delete"/>
													</div>
													&nbsp;
													Total records: <c:out value="${userFilter.paging.totalResults}"/>
													&nbsp;&nbsp;&nbsp;
													<sf:errors path="selectedContentIds" cssClass="error"/>
												</td>
											</tr>
										</tbody>
										</table>
									</td>
								</tr>
								<tr>
									<td height="25" width="1000%" align="left" valign="middle"><hr/></td>
								</tr>
								<tr>
									<td width="100%" align="left" valign="top">
									<!--Start Content-->
									<div name="errmsg" id="errmsg">
									<font color="red"><c:if test="${not empty errmsg}">${errmsg}</c:if></font>	
									<br/>
									</div>
										<table border=1 width="99%" cellpadding="5" cellspacing="0" class="linebox"><tbody>
											<tr class="greyheader">
												<jsp:include page="../../views/include/pagetr.jsp">
													<jsp:param name="page" value="${userFilter.paging.page}"/>
													<jsp:param name="maxPage" value="${userFilter.paging.maxPage}"/>
												</jsp:include>
											</tr>
											<tr class="header">
												<td></td>
												<td style="cursor: pointer" onClick="onOrder('id')">
													Id
													<c:choose><c:when test="${userFilter.ordering.orderBy eq 'id'}">
														<c:choose><c:when test="${userFilter.ordering.orderAsc}">
															<img src="ico/sort_up.png"/>
														</c:when><c:otherwise>
															<img src="ico/sort_down.png"/></c:otherwise>
														</c:choose>
													</c:when>
														<c:otherwise><img src="ico/sort.png"/></c:otherwise>
													</c:choose>
												</td>
												<td style="cursor: pointer" onClick="onOrder('username')">
													Username
													<c:choose><c:when test="${userFilter.ordering.orderBy eq 'username'}">
														<c:choose><c:when test="${userFilter.ordering.orderAsc}">
															<img src="ico/sort_up.png"/>
														</c:when><c:otherwise>
															<img src="ico/sort_down.png"/></c:otherwise>
														</c:choose>
													</c:when>
														<c:otherwise><img src="ico/sort.png"/></c:otherwise>
													</c:choose>
												</td>
												<td style="cursor: pointer" onClick="onOrder('email')">
													Email
													<c:choose><c:when test="${userFilter.ordering.orderBy eq 'email'}">
														<c:choose><c:when test="${userFilter.ordering.orderAsc}">
															<img src="ico/sort_up.png"/>
														</c:when><c:otherwise>
															<img src="ico/sort_down.png"/></c:otherwise>
														</c:choose>
													</c:when>
														<c:otherwise><img src="ico/sort.png"/></c:otherwise>
													</c:choose>
												</td>
												<td>Role</td>
											</tr>
											<c:forEach items="${contentList}" var="content" varStatus="contentStatus">
											<tr>
												<td><sf:checkbox path="selectedContentIds[${contentStatus.index}]"/></td>
												<td><c:out value="${content.id}"/></td>
												<td><c:out value="${content.username}"/></td>
												<td><c:out value="${content.email}"/></td>
												<td><c:out value="${content.role.name}"/></td>
											</tr>
											</c:forEach>
										</tbody></table>
									</td>
								</tr>
							</tbody></table>
							<br/>
						</td>
					</tr>
				</tbody>
			</table>
			<br/>
			</td>
		</tr>
	</table>
</td></tr>
</tbody>
</table>

	<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
	<sf:hidden path="ordering.orderBy"/>
	<sf:hidden path="ordering.orderAsc"/>
</sf:form>
</body>
</html>